package demo2;

public class Student implements Comparable<Student>,Cloneable{
    public String name;
    public int age;
    public double score;
    public Money money=new Money();

    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    public int compareTo(Student o) {
        return 0;
    }

//    @Override
//    protected Object clone() throws CloneNotSupportedException {
//        return super.clone();
//    }//浅拷贝

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student tmp=(Student) super.clone();
        tmp.money=(Money) this.money.clone();//this.money是Money类的成员变量，记得要强转为Money
        return tmp;
    }
}
